﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using AdventureWorks.Domain;
using AdventureWorks.DataAccess.Task;
using AdventureWorks.DataAccess.SearchCriterias;

namespace AdventureWorks.Services
{
    
    public class ProductService : IProductService
    {
        private IProductTask task; 

        public ProductService()
        {
            task = new ProductTask();
        }

        public IList<Product> GetProducts(string category, string name, string productNumber)
        {
            int? categoryId = category == null ? null : (int?)((ProductCategory?)Enum.Parse(typeof(ProductCategory), category));
            //var criteria = new ProductSearchCriteria { Name = name, ProductNumber = productNumber, StandardCost = standardCost, SubCategory = subCategory, Category = categoryId };
            var criteria = new ProductSearchCriteria { Name = name, ProductNumber = productNumber, Category = categoryId };
            return new List<Product>(task.GetSpecialOffers(criteria).PageResult);
        }
        
    }
}
